<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script src="graph.js"></script>
    <script>
        var graph = new Graph();
        // 添加顶点
        var myVertexes = ["A", "B", "C", "D", "E", "F", "G", "H", "I"]

        // 添加顶点
        for (var i = 0; i < myVertexes.length; i++) {
            graph.addVertex(myVertexes[i]);
        }

        // 添加边
        graph.addEdges('A', 'B');
        graph.addEdges('A', 'C');
        graph.addEdges('A', 'D');
        graph.addEdges('C', 'D');
        graph.addEdges('C', 'G');
        graph.addEdges('D', 'G');
        graph.addEdges('D', 'H');
        graph.addEdges('B', 'E');
        graph.addEdges('B', 'F');
        graph.addEdges('E', 'I');

        console.log(graph.toString());

        // console.log(graph.initializeColor());

        var str = '';
        graph.bfs(graph.vertexes[0], function (v) {
            str += v + '';
        })
        console.log(str);

        var str = '';
        graph.dfs(graph.vertexes[0], function (v) {
            str += v + '';
        })
        console.log(str);

    </script>

</body>

</html>